import { useSelector, useDispatch } from "react-redux"
import numStatus from "@/store/NumStatus"

const View = () => {
    const dispatch = useDispatch();

    // 获取数据
    const { num, sarr } = useSelector((state: RootState) => ({
        num: state.handleNum.num,
        sarr: state.handleArr.sarr
    }));
    // 修改数据

    const changeNum = () => {
        dispatch({ type: 'add2', val: 100 })
    }

    const changeNum2 = () => {
        dispatch(numStatus.asyncActions.asyncAdd1)
    };


    const changeArr = () => {
        dispatch({ type: "sarrpush", val: 100 })
    }

    return (
        <div className='home'>
            <p>这是Page1页面内容</p>
            <p>{num}</p>
            <button onClick={changeNum}>按钮</button>
            <button onClick={changeNum2}>异步按钮</button>

            <p>{sarr}</p>
            <button onClick={changeArr}>按钮</button>
        </div>
    )
}
export default View